<?php
namespace app\article\validate;
use think\Validate;
class ContactUs extends Validate {
    //验证字段
    protected $rule = [
        'id' => ['require','number'],
        'address' => ['require'],
        'phone' => ['require','number'],
        'url' => ['require'],
        'qq' => ['require','number'],
        'wechat' => ['require'],
        'qr_code' => ['require'],
        'status' => ['require','number'],
        'creater' => ['require'],
        'create_time' => ['require'],
        'updater' => ['require'],
        'update_time' => ['require'],
    ];
    //返回消息
    protected $message = [
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
        'address.require' => '地址必须',
        'phone.require' => '电话必须',
        'phone.number' => '电话不是数字',
        'url.require' => '网址必须',
        'qq.require' => 'qq必须',
        'qq.number' => 'qq不是数字',
        'wechat.require' => '微信必须',
        'qr_code.require' => '二维码图片必须',
        'status.require' => '状态值必须',
        'status.number' => '状态值不是数字',
        'creater.require' => '创建者必须',
        'create_time.require' => '创建时间必须',
        'updater.require' => '更新者必须',
        'update_time.require' => '更新时间必须',
    ];

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['id','address','phone','url','qq','wechat','qr_code','status','creater','create_time','updater','update_time']);
    }

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['address','phone','url','qq','wechat','qr_code','status','creater','create_time','updater','update_time']);
    }
}
